package com.jvup.gameshow.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.jvup.common.support.base.BaseFragment;
import com.jvup.common.constant.Navigation;
import com.jvup.common.inject.EventControllerInjector;
import com.jvup.gameshow.R;
import com.jvup.gameshow.controller.PlayerShowController;
import com.jvup.gameshow.databinding.FragmentPlayerShowBinding;
import com.jvup.gameshow.model.viewModel.impl.PlayerShowViewModel;
import com.qire.antsbinder.viewModel.ViewModelFactory;
import com.qire.antscore.annotation.RouteMapping;
import com.qire.antsrouter.inject.Autowired;

@RouteMapping(path = Navigation.Fragment.PlayerShowFragment)
public class PlayerShowFragment extends BaseFragment<FragmentPlayerShowBinding> {

    private PlayerShowViewModel viewModel;

    @Autowired(injector = EventControllerInjector.class)
    private PlayerShowController controller;

    @Override
    public int layoutRid() {
        return R.layout.fragment_player_show;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        FragmentPlayerShowBinding viewDataBinder = viewDataBinder(inflater,container);

        viewModel = ViewModelFactory.crateByDex(getActivity(),PlayerShowViewModel.class);

        viewModel.initView(inflater, container, controller);

        viewDataBinder.setPlayerShowViewModel(viewModel.proxy());

        viewDataBinder.playerShowZoneTab.setupWithViewPager(viewDataBinder.playerShowZone);
        viewDataBinder.playerShowZone.setPageTransformer(false, controller::transformPage);
        return viewDataBinder.getRoot();
    }

}
